﻿<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/REC-html40/loose.dtd">
<!-- saved from url=(0086)http://169.254.158.100/zzdl/ContApply/Apply_Exam.asp?p_Applyno=10002010182564&p_type=4 -->
<HTML xmlns:th="http://www.thymeleaf.org">
<HEAD><TITLE>财务部长审批合同申请</TITLE>
    <!--导入vue依赖-->
    <script th:src="@{/js/vue2.js}"></script>
    <!--导入axios依赖-->
    <script th:src="@{/js/axios.js}"></script>
    <!--导入分页组件-->
    <script th:src="@{/js/vuejs-paginate.js}"></script>
    <!--导入BootStrap框架所需的三个依赖-->
    <script th:src="@{/js/jquery.min.js}"></script>
    <SCRIPT language=JAVASCRIPT>
        function chck() {
            var count = 0;
            for (var i = 0; i < form.length; i++)
                if ((form[i].type == "radio") && (form[i].checked))
                    count++;
            if (count == 0) {
                return false;
            } else {
                return true;
            }
        }

        function Add(SourceList, TargetList) {
            var nIndex = SourceList.selectedIndex;
            var nCount = 0;
            if (nIndex == -1) {
                // Process continue only if at least one item selected
                //alert("请先选择一项!");
                return;
            }
            for (i = 0; i < SourceList.length; i++) {
                if (SourceList.options(i).selected == true) {
                    if (inSouceList(SourceList.options(i).value, TargetList) == false) {
                        var objSelected = new Option(SourceList[i].text, SourceList[i].value);
                        TargetList.options[TargetList.length] = objSelected;
                    }
                }
            }
            for (var i = 0; i < TargetList.options.length; i++) {
                TargetList.options(i).selected = true;
            }
            if (navigator.appName == "Netscape") {
                history.go(0)
            }
        }

        function inSouceList(SourceListOption, TargetList) {
            for (i = 0; i < TargetList.length; i++) {
                if (TargetList.options[i].value == SourceListOption) {
                    return true;
                }
            }
            return false;
        }

        function Remove(SelectList) {
            var nIndex = SelectList.selectedIndex;
            var nCount = 0;
            if (nIndex == -1) {
                // Process continue only if at least one item selected
                //alert("请先选择一项!");
                return;
            }
            while (nCount < SelectList.length) {
                if (SelectList.options(nCount).selected == true) {
                    SelectList.options[nCount] = null;
                } else {
                    nCount++;
                }
            }
            if (navigator.appName == "Netscape") {
                history.go(0)
            }
        }

        function enter() {
            var srcEle = window.event.srcElement;
            var tmp;
            tmp = window.showModalDialog("pub_pub.Dialog_Date?vc_input=" + srcEle.value);
            if (tmp.indexOf("/") != -1) {
                srcEle.value = tmp;
            }
            return;
        }

        function check_num() {
            if (window.event.keyCode > 57 || window.event.keyCode < 48) {
                window.event.returnValue = false;
            }
        }

        function check_blank() {
            if (window.event.keyCode < 48) {
                window.event.returnValue = false;
            }
        }

        function check_num_dot() {
            if (window.event.keyCode > 57 || window.event.keyCode < 46) {
                window.event.returnValue = false;
            } else {
                if (window.event.keyCode == 47) {
                    window.event.returnValue = false;
                }
                if (window.event.keyCode == 46) {
                    if (window.event.srcElement.value.indexOf(".") != -1) {
                        window.event.returnValue = false;
                    }
                }
            }
        }

        function submitonce(theform) {
            if (document.all || document.getElementById) {
                for (i = 0; i < theform.length; i++) {
                    var tempobj = theform.elements[i]
                    if (tempobj.type.toLowerCase() == "button")
                        tempobj.disabled = true
                }
            }
        }

        function CheckAll() {
            var i = 0;
            for (i = 0; i < window.document.forms[0].elements.length; i++) {
                if (window.document.forms[0].elements[i].Chk < 3) {
                    if (window.document.forms[0].elements[i].value == "") {
                        alert(window.document.forms[0].elements[i].alt);
                        window.document.forms[0].elements[i].focus();
                        return;
                    } else if (window.document.forms[0].elements[i].Chk == 2) {
                        if (NotNumber(window.document.forms[0].elements[i].value)) {
                            alert("提示信息：\n不是有效的数字，请重新输入。");
                            window.document.forms[0].elements[i].focus();
                            return;
                        }
                    }
                } else if (window.document.forms[0].elements[i].Chk == 3) {
                    if (window.document.forms[0].elements[i].value != "") {
                        if (NotNumber(window.document.forms[0].elements[i].value)) {
                            alert("提示信息：\n不是有效的数字，请重新输入。");
                            window.document.forms[0].elements[i].focus();
                            return;
                        }
                    }
                }
            }
            window.document.forms[0].submit();
            return true;
        }

        function NotNumber(Field) {
            var j = 0;
            var k = 0;
            for (var i = 0; i < Field.length; i++) {
                var ch = Field.substring(i, i + 1);
                if ((ch >= "0") && (ch <= "9")) {
                    j = 0;
                } else if (ch == ".") {
                    k++;
                } else {
                    j = 1;
                    break;
                }
            }
            if ((j == 0) && (k < 2)) {
                return false;
            } else {
                return true;
            }
        }

        function openwindown(page) {
            window.open(page, "newuser", "toolbar=no,location=no,directories=no,status=no,menubar=no,scrollbars=yes,resizable=yes,width=700,height=400,left=100,top=150");
        }

        function back() {
            location.href = "Apply_daishencaiwu.html";
        }
    </SCRIPT>

    <META http-equiv=Content-Language content=zh-cn>
    <META http-equiv=Content-Type content="text/html; charset=gb2312">
    <META content="MSHTML 6.00.2900.5626" name=GENERATOR>
    <META content=FrontPage.Editor.Document name=ProgId>
    <LINK
            href="css/style.css" rel=stylesheet>
</HEAD>
<BODY>
<div id="app">
    <CENTER>
        <CENTER>
            <TABLE style="LINE-HEIGHT: 30px" cellSpacing=1 cellPadding=0 width="100%"
                   bgColor=#336699 borderColorLight=#006699 border=0>
                <TBODY>
                <TR>
                    <TD>
                        <TABLE cellSpacing=1 cellPadding=3 width="100%" border=0>
                            <TBODY>
                            <TR bgColor=#ffffff>
                                <TD align=middle width="100%" bgColor=#ffffff colSpan=20
                                    height=22>
                                    <H2><FONT color=#0070c0><B>采购计划审批</B>
                                        <IMG alt=帮助
                                             src="img/help_a.gif" border=0></FONT></H2></TD>
                            </TR>
                            <TR class=t1>
                                <TD width="20%">询价书名称：</TD>
                                <TD class=t2 width="30%"><A
                                        href="javascript:void(0)" @click="apply(enquireId)">{{ enquireName }}</A></TD><!--<td>合同编号：</td>
  <td colspan=2>W20100040</td>-->
                                <TD width="20%">采购计划名称：</TD>
                                <TD class=t2 width="30%">{{ stockName }}</TD>
                            </TR>
                            <TR class=t1>
                                <TD width="20%">采购类型：</TD>
                                <TD class=t2 width="30%">{{ stockType }}</TD>
                                <TD width="20%">预算金额（元）：</TD>
                                <TD class=t2
                                    width="30%">{{ budget }}
                                </TD>
                            </TR>
                            </TBODY>
                        </TABLE>
                    </TD>
                </TR>
                </TBODY>
            </TABLE>
            <TABLE style="LINE-HEIGHT: 30px" cellSpacing=1 cellPadding=0 width="100%"
                   bgColor=#336699 borderColorLight=#006699 border=0>
                <TBODY>
                <TR>
                    <TD>
                        <TABLE cellSpacing=1 cellPadding=3 width="100%" border=0>
                            <TBODY>
                            <TR class=t1>
                                <TD noWrap align=middle width="20%">采购计划编号</TD>
                                <TD noWrap align=middle>采购计划名称</TD>
                                <TD noWrap align=middle>采购类型</TD>
                                <TD noWrap align=middle>预算金额<BR>（元）</TD>
                                <TD noWrap align=middle>计划询价开始时间</TD>
                                <TD noWrap align=middle>计划报价截止时间</TD>
                            </TR>
                            <TR class=t2 v-for="(stock,index) in searchResult.data">
                                <TD width="20%"><A
                                        href="javascript:void(0)"><FONT
                                        color=green>{{ stock.STOCK_NUM }}</FONT></A><BR></TD>
                                <TD align=right>{{ stock.STOCK_NAME }}<BR></TD>
                                <TD align=right>{{ stock.STOCK_TYPE }}<BR></TD>
                                <TD align=right>{{ stock.BUDGET }}<BR></TD>
                                <TD align=right>{{ stock.START_DATE }}<BR></TD>
                                <TD align=right>{{ stock.END_DATE }}<BR></TD>
                            </TR>
                            </TBODY>
                        </TABLE>
                    </TD>
                </TR>
                </TBODY>
            </TABLE>
        </CENTER>
        <TD
                align="left"><FONT
                color=red>说明：系统中供应商名称用蓝色表示为合格供方，绿色表示为许可供方，红色表示为其他供方；数量为红色表示报价数量与询价数量不相等。</FONT>
        </TD>

        <FORM name=form action=Apply_Exam_Save.asp method=post>
            <TABLE style="LINE-HEIGHT: 30px" cellSpacing=1 cellPadding=0 width="100%"
                   bgColor=#336699 borderColorLight=#006699 border=0>
                <TBODY>
                <TR>
                    <TD>
                        <TABLE cellSpacing=1 cellPadding=3 width="100%" border=0>
                            <TBODY>
                            <TR class=t1>
                                <TD width="20%">是否同意</TD>
                                <TD><INPUT type=radio CHECKED value="S001-30" name="p_agree">同意 <INPUT
                                        type=radio value="S001-10" name="p_agree">驳回<INPUT
                                        type=radio value="S001-20" name="p_agree">待审<INPUT
                                        type=radio value="S001-00" name="p_agree">废弃
                                </TD>
                            </TR>
                            <TR class=t1>
                                <TD width="20%">审批意见</TD>
                                <TD><TEXTAREA id="p_idea" name="p_idea" rows=3 cols=60>  </TEXTAREA>
                                </TD>
                            </TR>
                            </TBODY>
                        </TABLE>
                    </TD>
                </TR>
                </TBODY>
            </TABLE>
            <TABLE cellSpacing=1 cellPadding=0 width="100%" bgColor=#ffffff
                   borderColorLight=#ffffff border=0>
                <TBODY>
                <TR>
                    <TD>
                        <TABLE cellSpacing=1 cellPadding=3 width="100%" border=0>
                            <TBODY>
                            <TR>
                                <TD align=right>
                                    审批人 <INPUT
                                        style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-BOTTOM-COLOR: black; BORDER-LEFT: 0px; WIDTH: 80px"
                                        readOnly maxLength=20 th:value="${session.userName}" id="p_spr" name="p_spr">&nbsp;
                                    &nbsp;
                                    审批时间 <INPUT
                                        style="BORDER-RIGHT: 0px; BORDER-TOP: 0px; BORDER-BOTTOM-COLOR: black; BORDER-LEFT: 0px; WIDTH: 80px"
                                        readOnly maxLength=20 :value="nowDate" id="p_spsj" ame="p_spsj">
                                </TD>
                            </TR>
                            </TBODY>
                        </TABLE>
                    </TD>
                </TR>
                </TBODY>
            </TABLE>
            <INPUT type=hidden
                   value=10002010182564 name=p_Applyno> <INPUT type=hidden value=4 name=p_type>
            <BR><INPUT @click="queding" type=button value=确定> <INPUT onclick="back()" type=button value=返回>
        </FORM>
    </CENTER>
</div>
</BODY>


<script>
    var app = new Vue({
        el: "#app",
        data: {
            stockId: -1,
            userName: '', // 当前登录用户
            nowDate: '', // 当前日期
            enquireId: 0, // 询价书id
            enquireName: '', // 询价书名称
            stockName: '', // 采购计划名称
            stockType: '', // 采购类型
            budget: 0, // 预算金额
            searchResult: {//后端响应的结果

            },
        },
        methods: {
            init() {
                axios.get('/stock/getbyid', {
                    params: {
                        id: this.stockId
                    }
                }).then(result => {
                    this.searchResult = result.data
                    console.log(this.searchResult)
                    if (this.searchResult.data) {
                        this.enquireName = this.searchResult.data[0].ENQUIRE_NAME;
                        this.stockName = this.searchResult.data[0].STOCK_NAME;
                        this.stockType = this.searchResult.data[0].STOCK_TYPE;
                        this.budget = this.searchResult.data[0].BUDGET;

                    }
                })
            },
            queding() {
                var p_agree = $('input[name=p_agree]:checked').val();
                var p_areee_text = '';
                if (p_agree == 'S001-30') {
                    p_areee_text = '同意';
                } else if (p_agree == 'S001-20') {
                    p_areee_text = '待审';
                } else if (p_agree == 'S001-10') {
                    p_areee_text = '驳回';
                } else if (p_agree == 'S001-00') {
                    p_areee_text = '废弃';
                }
                var p_idea = $("#p_idea").val();
                var p_spr = $("#p_spr").val();
                var p_spsj = $("#p_spsj").val();
                console.log(p_agree + "," + p_idea + "," + p_spr + "," + p_spsj)
                if (confirm('您确认信息正确并通过吗？')) {
                    axios.post('/stock/updateByPrimaryKeySelective', {

                        id: this.stockId,
                        leadOpinion: p_idea,
                        stockStatus: p_agree,
                        leadAgree: p_areee_text,
                        leader: p_spr,
                        leadDate: p_spsj

                    }).then(result => {
                        if (result.code = 200) {
                            window.document.location = "Apply_daishencaiwu.html";
                        } else {
                            alert("审批失败，请重新操作")
                        }
                    })
                }
            },
            apply() {
                sessionStorage.setItem('id', this.enquireId);
                //获取数据
                const value = sessionStorage.getItem('id');
                console.log(value);
                //跳转到Enquire_bianzhi.html页面
                window.location.href = 'Enquire_bianzhi.html';
            },
        },
        created() {
            // 获取当前日期
            var date = new Date();
            var year = date.getFullYear();
            var month = date.getMonth() + 1;
            var strDate = date.getDate();
            if (month >= 1 && month <= 9) {
                month = "0" + month;
            }
            if (strDate >= 0 && strDate <= 9) {
                strDate = "0" + strDate;
            }
            this.nowDate = year + "-" + month + "-" + strDate;

            this.stockId = sessionStorage.getItem('stockId');
            this.enquireId = sessionStorage.getItem('id');
            this.init();
        },

    })

</script>
</HTML>
